import 'package:flutter/material.dart';

import './person.dart';

class InheriedDataWidget extends InheritedWidget {
  final Person person;
  final Widget child;

  const InheriedDataWidget({super.key, required this.person, required this.child}) 
    : super(child: child);

  static InheriedDataWidget? of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<InheriedDataWidget>();
  }

  @override
  bool updateShouldNotify(InheriedDataWidget oldWidget) {
    return this.person.name != oldWidget.person.name ||
      this.person.age != oldWidget.person.age;
  }
}